from flask import Flask as _Flask

from apps.api import create_blueprint_v1
from apps.config import secure, setting

from flask.json import JSONEncoder as _JSONEncoder

#模型转字典
from apps.libs.error_code import ServerError


class JSONEncoder(_JSONEncoder):
    def default(self, o):
        if hasattr(o, 'keys') and hasattr(o, '__getitem__'):
            return dict(o)
        raise ServerError()


class Flask(_Flask):
    json_encoder = JSONEncoder


